Network Monitoring
-
Use the
NetworkMonitor
class to determine the current status of the iOS device’s connection to the internet.To get the type of network connection currently available, use
currentNetworkConnection
. If thecurrentNetworkConnection
is WWAN, you can narrow down the type further withcellularNetworkType
, which shows whether the device is using 4G, 3G, or 2G.To subscribe to network changes, call
See morestartMonitoringNetworkChanges()
and add an observer toNotificationCenter.default
withNetworkMonitor.networkChangedNotificationName
as the notification name. To turn off these notifications, callstopMonitoringNetworkChanges()
.Declaration
Swift
public class NetworkMonitor
-
Describes how the device is currently connected to the internet.
See moreDeclaration
Swift
public enum NetworkConnection